import Vue from 'vue';
import BuyMemberPopupView from './BuyMemberPopup.vue';

let PopupConstructor = Vue.extend(BuyMemberPopupView);

PopupConstructor.prototype.close = function () {
  if (this.$el && this.$el.parentNode) {
    this.$el.parentNode.removeChild(this.$el);
  }
  this.$destroy();
  document.body.style.overflow = '';
};

let instance;

const BuyMemberPopup = (options = {}) => {
  instance = new PopupConstructor({
    data: options
  });

  instance.$mount();
  document.body.appendChild(instance.$el);
  document.body.style.overflow = 'hidden';
  document.body.style.position = 'fixed';
  document.body.style.scroll = 'no';

  instance.visible = true;

  instance.$el.style.zIndex = 999;

};

export default BuyMemberPopup;
